/**
 *  Attributes for a var Ident or an Array ident. We need
 *  name + type + scope in general - type is already an attribute of GenericAttribute.
 *  Notice the param attribute, used to mark an ident as a function argument.
 *  The interface methods isParam is necessary for MIPS code generation. Not used
 *  in the VSM code generator.
 * @author MLB
 *
 */
public class VarAttribute extends GenericAttribute {
	public String name;
	public int scope;
	public boolean param;

	/**
	 *  For integer variable. The default value of param may be override by the setParam method.
	 *  type is T_integer
	 * @param n string: the name of the id
	 * @param sc int: the declaration scope
	 */
	public VarAttribute(String n, int sc) {
		super(TypeSystem.T_integer);
		name = n;
		scope = sc;
		param = false;
	}
	/**
	 * For temporary idents - scope  is meaningless
	 * @param n string: the name of the id
	 */
	public VarAttribute(String n) { 
		super(TypeSystem.T_integer);
		name = n;
		scope = -1;
	}

	/**
	 * For array idents
	 * @param t ArrayType
	 * @param n string: the name of the id
	 * @param sc int: the declaration scope
	 */
	public VarAttribute(Type t, String n, int sc) { 
		super(t);
		name = n;
		scope = sc;
	}

	/**
	 * for code 3a printing
	 */
	public String getName3a() {
		return name;
	}

	/**
	 * Self explained
	 */
	public int getScope() {
		return scope;
	}
	
	/**
	 * Put param attribute to true
	 */
	public void setParam(){
		param = true;
	}
	
	/**
	 * MIPS code generator interface only
	 */
	public boolean isParam(){
		return param;
	}
}
